package Solution;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-01-20
 * Time: 19:10
 */

//https://leetcode.cn/problems/add-digits/description/
class Solution8 {
    public int addDigits(int num) {
        int sum = num;
        while (sum / 10 != 0) {
            sum = 0;
            while (num != 0) {
                sum += num % 10;
                num /= 10;
            }
            num = sum;
        }
        return sum;
    }
}
